package cn.zktr.Personnel.model.service.zhouyongcong.monit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.zktr.Personnel.model.pojos.PerAudit;
import cn.zktr.Personnel.model.pojos.PerCwaQLae;
import cn.zktr.Personnel.model.pojos.PerCwaQts;
import cn.zktr.Personnel.model.service.zhouyongcong.boolService;
import cn.zktr.Personnel.model.service.zhouyongcong.findService;
import cn.zktr.Personnel.model.service.zhouyongcong.saveService;

@Service
@Transactional(rollbackFor=Exception.class)
public class monitsaveService {
	@Autowired
	private findService fs;
	@Autowired
	private saveService ss;
	@Autowired
	private boolService bl;
	@Autowired
	private monitService ms;
	@Autowired
	private monitfindService mfs;
	
	public boolean save(Integer empid,monitObj[] mo,Integer shlxid) {
		int cha = fs.findAllAuditlenght(shlxid).size();
		PerAudit pa = fs.findAuditid(bl.bool_Audit());
		for(monitObj mon : mo) {
			if(mon.isAdd()) {
				ms.save(mon.getOld_obj(),mon.getNew_obj(),pa,cha,mon.isDle());
			}else{
				ms.save(mon.getOld_obj(),mon.getNew_obj(),pa,0,mon.isDle());
			}
		}
		if(pa.getPerPmsEmp1().getEmpid()==empid&&pa.getPerPmsEmp2().getEmpid()==empid) {
			mfs.find(pa.getPerAuditMdies());
		}
		return true;
	}
	public boolean save_08(int empid, PerCwaQLae lae) {
		int cha = fs.findAllAuditlenght(8).size();
		ss.save_Audit_id(8,lae.getPerPmsEmp().getEmpid(),"员工请假审核", fs.findEmpid(lae.getPerPmsEmp().getEmpid()).getEmpname()+"申请请假，请审核！");
		PerAudit pa = fs.findAuditid(bl.bool_Audit());
		ms.save(lae,pa,cha);
		return true;
	}
	public boolean save_09(int empid, PerCwaQts qts) {
		int cha = fs.findAllAuditlenght(9).size();
		ss.save_Audit_id(9,qts.getPerPmsEmp().getEmpid(),"员工加班审核", fs.findEmpid(qts.getPerPmsEmp().getEmpid()).getEmpname()+"申请加班，请审核！");
		PerAudit pa = fs.findAuditid(bl.bool_Audit());
		ms.save(qts,pa,cha);
		return true;
	}
}
